package ltd.jdsoft.cute.common.session;

/**
 * 线程相关的一些session信息可以保存起来，其他地方可以方便的获取
 * 
 * @author zhengzhq
 *
 */
public class SecuritySession {

  private static ThreadLocal<Object> THREAD_SESSION = new ThreadLocal<Object>();

  public static void set(Object session) {
    THREAD_SESSION.set(session);
  }

  public static Object get() {
    return THREAD_SESSION.get();
  }

  @SuppressWarnings("unchecked")
  public static <T> T get(Class<T> type) {
    return (T) THREAD_SESSION.get();
  }

  public static void clearOnOver() {
    THREAD_SESSION.remove();
  }
}
